package controller

import (
	"hft/Database/admin"
	"hft/Http/Models/request"
	services "hft/Http/Services"
	utils "hft/Http/Utils"

	"github.com/gin-gonic/gin"
)

type RoomType struct{}

func (*RoomType) CreateRoom(c *gin.Context) {
	var room *admin.RoomType

	c.ShouldBindJSON(&room)

	err := services.RoomServices.CreateRoom(room)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}
	utils.Ok(c)
}

func (*RoomType) EditRoom(c *gin.Context) {
	var room *admin.RoomType

	c.ShouldBindJSON(&room)

	err := services.RoomServices.EditRoom(room)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}
	utils.Ok(c)
}

func (*RoomType) GetRoomList(c *gin.Context) {

	list, err := services.RoomServices.GetRoomList()

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}
	utils.OkWithData(list, c)
}

func (*RoomType) Delete(c *gin.Context) {
	var IDS *request.IDS

	c.ShouldBindJSON(&IDS)

	err := services.RoomServices.DeleteType(IDS.IDS)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.Ok(c)
}

var RoomController = new(RoomType)
